package com.imeth.cms.dao;

import com.imeth.base.MyBatisDao;
import com.imeth.base.model.Paging;
import com.imeth.cms.Fragment;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by peter on 12/24/2015.
 */
@MyBatisDao
public interface FragmentDao {

    @Options(useGeneratedKeys=true, keyProperty="id")
    @Insert("insert into t_fragment(name,description) values(#{name},#{description})")
    int save(Fragment fragment);

    @Update("update t_fragment set name=#{name},description=#{description} where id=#{id}")
    int update(Fragment fragment);

    @Delete("delete from t_fragment where id = #{id}")
    int deleteById(Integer id);

    @Select("select * from t_fragment where id=#{id}")
    Fragment getById(Integer id);

    @Select("select count(1) from t_fragment")
    int count();

    @Select("select * from t_fragment limit #{startRow},#{pageSize}")
    List<Fragment> query(Paging paging);
}
